/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pt.iasd.youthshelter.wizards.core;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import pt.iasd.youthshelter.datamodel.Honor;
import pt.iasd.youthshelter.datamodel.Lider;
import pt.iasd.youthshelter.datamodel.Pathfinder;

/**
 *
 * @author Rui
 */
public class ListSorter {
    /**
     * Sort list of pathfinders by name.
     * @param pathfinders List of pathfinders.
     * @return Sorted list of pathfinders.
     */
    public static List<Pathfinder> sortPathfindersByName(List<Pathfinder> pathfinders) {
        if(pathfinders != null && pathfinders.size() > 1) {
            Collections.sort(pathfinders, new Comparator<Pathfinder>() {
                @Override
                public int compare(Pathfinder o1, Pathfinder o2) {
                    return o1.getName().compareTo(o1.getName());
                }
            });
        }
        return pathfinders;
    }
    
    /**
     * Sort list of liders by name.
     * @param liders List of liders.
     * @return Sorted list of liders.
     */
    public static List<Lider> sortLidersByName(List<Lider> liders) {
        if(liders != null && liders.size() > 1) {
            Collections.sort(liders, new Comparator<Lider>() {
                @Override
                public int compare(Lider o1, Lider o2) {
                    return o1.getName().compareTo(o1.getName());
                }
            });
        }
        return liders;
    }
    
    /**
     * Sort list of honors by name.
     * @param honors List of honors.
     * @return Sorted list of honors.
     */
    public static List<Honor> sortHonorsByName(List<Honor> honors) {
        if(honors != null && honors.size() > 1) {
            Collections.sort(honors, new Comparator<Honor>() {
                @Override
                public int compare(Honor o1, Honor o2) {
                    return o1.getName().compareTo(o1.getName());
                }
            });
        }
        return honors;
    }
}
